package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.*;
import com.ruoyi.logistic.domain.vo.NetworkBillCollectNetVo;
import com.ruoyi.logistic.domain.vo.NetworkBillCollectSalesmanVo;
import com.ruoyi.logistic.service.NetworkBillCollectNetService;
import com.ruoyi.logistic.service.impl.NetworkBillCollectNetServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;
import java.util.List;

@RequestMapping("/network/billCollect")
@RestController
@Api(tags = "网点财务_网点揽收分润账单_账单汇总")
public class NetworkBillCollectController {
    @Autowired
    private NetworkBillCollectNetService networkBillCollectNetService;
    @ApiOperation("网点账单汇总")
    @PostMapping("/network")
    public R collectNetworkByDay(@RequestBody NetworkBillCollectNetVo networkBillCollectNetVo){
        NetworkBillCollectNet networkBillCollectNet = networkBillCollectNetService.collectNetworkByDay(networkBillCollectNetVo);
        if (networkBillCollectNet == null){
            return R.fail("暂无数据");
        }else {
            return R.ok(networkBillCollectNet);
        }
    }

    @ApiOperation("业务员账单汇总/按日汇总")
    @PostMapping("/salesman")
    public R collectSalesmanByDay(@RequestBody @Param("networkBillCollectSalesmanVo")NetworkBillCollectSalesmanVo networkBillCollectSalesmanVo,
                                   @Param("pageDate")PageDate pageDate){
        List<NetworkBillCollectSalesman> networkBillCollectSalesmen = networkBillCollectNetService.collectSalesmanByDay(networkBillCollectSalesmanVo,pageDate);
        if (networkBillCollectSalesmen == null){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(networkBillCollectSalesmen));
        }
    }

}
